<?php
/**
 * Created by PhpStorm.
 * User: 123
 * Date: 2020/8/3
 * Time: 14:42
 */

namespace app\api\controller;
use app\service\ResourceService;
use think\Db;

/**
 * banner相关
 * @author   juzi
 * @blog    https://blog.csdn.net/juziaixiao
 * @version  0.0.1
 * @datetime 2020年7月22日10:57:35
 */
class Banner extends Common
{
    /**
     * [__construct 构造方法]
     * @author   juzi
     * @blog    https://blog.csdn.net/juziaixiao
     * @version  0.0.1
     * @datetime 2020年7月22日10:57:35
     */
    public function __construct()
    {
        // 调用父类前置方法
        parent::__construct();
    }

    /**
     * [Index 获取列表]
     * @author   Devil
     * @blog     http://gong.gg/
     * @version  0.0.1
     * @datetime 2017-02-22T16:50:32+0800
     */
    public function Index()
    {
        $type=empty(input('type'))?1:input('type');
        $res=Db::table('banner')->where('type='.$type)->find();
        if($res['type']==1){
            $res['type']='首页banner';
        }else{
            $res['type']='分类banner';
        }
        $_bannerurl=explode(",",$res["banner"]);
        if(!empty($_bannerurl)){
            foreach($_bannerurl as &$v)
            {
                $v=ResourceService::AttachmentPathViewHandle($v);
            }
        }
        return json(DataReturn('success', 0, $_bannerurl));
    }



}